import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// import '@/static/mdui/css/mdui.css'
import axios from './axios.config'
import apiConfig from '@/api/apiConfig'
import VueClipboard from 'vue-clipboard2'
import mdui from 'mdui'

Vue.config.productionTip = false

Vue.prototype.$axios = axios
Vue.prototype.$mdui = mdui

if (localStorage.getItem('token')) {
  const token = `${localStorage.getItem('token')}`
  store.commit('setToken', token)
  const conf = apiConfig.user.loginTest()
  axios(conf).catch(e => console.log(e))
} else {
  localStorage.clear()
}

if (localStorage.getItem('username')) {
  const user = `${localStorage.getItem('username')}`
  store.commit('setUser', user)
}

if (localStorage.getItem('isAdmin')) {
  const isAdmin = localStorage.getItem('isAdmin')
  store.commit('setAdmin', isAdmin)
}

Vue.use(VueClipboard)
new Vue({
  router,
  store,
  render: h => h(App)
  // comments: {
  //   App
  // }
}).$mount('#app')
